package com.tpc.jginterface.util.crypto;

import cn.hutool.crypto.SmUtil;
import cn.hutool.crypto.symmetric.SM4;

/**
 * @author duwenlei
 * @version 1.0
 * @ClassName SM4Util
 * @Date 2024/4/22 18:58
 * @Description SM4 工具
 */
public class SM4Util {

    public static byte[] generatorSM4() {
        SM4 sm4 = SmUtil.sm4();
        return sm4.getSecretKey().getEncoded();
    }

    public static byte[] encode(byte[] sm4Key, byte[] originData) {
        SM4 sm4 = SmUtil.sm4(sm4Key);
        return sm4.encrypt(originData);
    }

    public static byte[] decode(byte[] sm4Key, byte[] originData) {
        SM4 sm4 = SmUtil.sm4(sm4Key);
        return sm4.decrypt(originData);
    }

}
